// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// A request for connection information for a particular membership.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GenerateCredentialsRequest {
    /// Required. The Fleet membership resource.
    pub name: std::string::String,

    /// Optional. Whether to force the use of Connect Agent-based transport.
    ///
    /// This will return a configuration that uses Connect Agent as the underlying
    /// transport mechanism for cluster types that would otherwise have used a
    /// different transport. Requires that Connect Agent be installed on the
    /// cluster. Setting this field to false is equivalent to not setting it.
    pub force_use_agent: bool,

    /// Optional. The Connect Gateway version to be used in the resulting
    /// configuration.
    ///
    /// Leave this field blank to let the server choose the version (recommended).
    pub version: std::string::String,

    /// Optional. The namespace to use in the kubeconfig context.
    ///
    /// If this field is specified, the server will set the `namespace` field in
    /// kubeconfig context. If not specified, the `namespace` field is omitted.
    pub kubernetes_namespace: std::string::String,

    /// Optional. The operating system where the kubeconfig will be used.
    pub operating_system: crate::model::generate_credentials_request::OperatingSystem,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GenerateCredentialsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GenerateCredentialsRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [force_use_agent][crate::model::GenerateCredentialsRequest::force_use_agent].
    pub fn set_force_use_agent<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.force_use_agent = v.into();
        self
    }

    /// Sets the value of [version][crate::model::GenerateCredentialsRequest::version].
    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.version = v.into();
        self
    }

    /// Sets the value of [kubernetes_namespace][crate::model::GenerateCredentialsRequest::kubernetes_namespace].
    pub fn set_kubernetes_namespace<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.kubernetes_namespace = v.into();
        self
    }

    /// Sets the value of [operating_system][crate::model::GenerateCredentialsRequest::operating_system].
    pub fn set_operating_system<
        T: std::convert::Into<crate::model::generate_credentials_request::OperatingSystem>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.operating_system = v.into();
        self
    }
}

impl wkt::message::Message for GenerateCredentialsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.gkeconnect.gateway.v1.GenerateCredentialsRequest"
    }
}

/// Defines additional types related to [GenerateCredentialsRequest].
pub mod generate_credentials_request {
    #[allow(unused_imports)]
    use super::*;

    /// Operating systems requiring specialized kubeconfigs.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum OperatingSystem {
        /// Generates a kubeconfig that works for all operating systems not defined
        /// below.
        Unspecified,
        /// Generates a kubeconfig that is specifically designed to work with
        /// Windows.
        Windows,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [OperatingSystem::value] or
        /// [OperatingSystem::name].
        UnknownValue(operating_system::UnknownValue),
    }

    #[doc(hidden)]
    pub mod operating_system {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl OperatingSystem {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Windows => std::option::Option::Some(1),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("OPERATING_SYSTEM_UNSPECIFIED"),
                Self::Windows => std::option::Option::Some("OPERATING_SYSTEM_WINDOWS"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for OperatingSystem {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for OperatingSystem {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for OperatingSystem {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Windows,
                _ => Self::UnknownValue(operating_system::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for OperatingSystem {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "OPERATING_SYSTEM_UNSPECIFIED" => Self::Unspecified,
                "OPERATING_SYSTEM_WINDOWS" => Self::Windows,
                _ => Self::UnknownValue(operating_system::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for OperatingSystem {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Windows => serializer.serialize_i32(1),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for OperatingSystem {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<OperatingSystem>::new(
                ".google.cloud.gkeconnect.gateway.v1.GenerateCredentialsRequest.OperatingSystem",
            ))
        }
    }
}

/// Connection information for a particular membership.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GenerateCredentialsResponse {
    /// A full YAML kubeconfig in serialized format.
    pub kubeconfig: ::bytes::Bytes,

    /// The generated URI of the cluster as accessed through the Connect Gateway
    /// API.
    pub endpoint: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GenerateCredentialsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [kubeconfig][crate::model::GenerateCredentialsResponse::kubeconfig].
    pub fn set_kubeconfig<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
        self.kubeconfig = v.into();
        self
    }

    /// Sets the value of [endpoint][crate::model::GenerateCredentialsResponse::endpoint].
    pub fn set_endpoint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.endpoint = v.into();
        self
    }
}

impl wkt::message::Message for GenerateCredentialsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.gkeconnect.gateway.v1.GenerateCredentialsResponse"
    }
}
